#ifndef __DEVELOP_USR_DEF_H
#define __DEVELOP_USR_DEF_H

/*注: 本demo尚未完全适配XIP启动方式*/

// 0-无调试数据 4-时域8bit输出(8*32个chirp) 5-时域加和伪浮点输出(32个chirp)(该模式已不可用) 10-寄存器输出
// 1-运动 fft1d调试数据adc(加和前的8个chirp)、 fft1d、fft1d-mean(天线1、天线2)
// 2-运动 fft2d调试数据adc(加和前的8个chirp)、fft1d-mean、fft2d (天线1、天线2)
// 3-运动 cfar数据数据 adc(加和前的8个chirp)、fft1d、fft2d、cfar数据(天线1)
// 6-存在 天线1 fft1d、均值、2d、cfar
// 7-存在 天线2 fft1d、均值、2d
// 8-合并后 点云RV图
// 9-存在 天线1 fft1d均值实时输出
// 11-存在天线1 2d、cfar 合并后点云RV图 周期输出
// 13-gpio输出测试
#define TEST_MODE (0)

#if 1 /* 雷达特性、主板选择*/
//#define MANUAL_FEATURE_SELECT  // 手动选择特性
#if defined(MANUAL_FEATURE_SELECT)      // 手动选择特性
#define BOARD_ID                   (0)  // 0-用户板 1-EVB 2-EVM-1T2R 3-EVM-1T1R 4-EVM2-1T2R
#define RAMP_BANDWIDTH             (0)  // 0-220M 1-800M
#define POINTRST_USER_PROCESS      (1)  // 点云处理
#define ULTRA_LPW                  (0)  // 超低功耗  // todo 适配xip
#define DEMO_RX_ANT_NUM            (2)  // 1-1T1R 2-1T2R
#else
//#define BOARD_EVB_220M
#define BOARD_EVB_220M_PROCESS
//#define ULTRA_LPW_BOARD_EVB_220M
//#define ULTRA_LPW_BOARD_EVB_220M_PROCESS
//#define BOARD_EVB_800M
//#define BOARD_EVB_800M_PROCESS
//#define ULTRA_LPW_BOARD_EVB_800M
//#define ULTRA_LPW_BOARD_EVB_800M_PROCESS

//#define BOARD_EVM_1T1R_220M
//#define BOARD_EVM_1T1R_220M_PROCESS
//#define ULTRA_LPW_BOARD_EVM_1T1R_220M
//#define ULTRA_LPW_BOARD_EVM_1T1R_220M_PROCESS
//#define BOARD_EVM_1T1R_800M
//#define BOARD_EVM_1T1R_800M_PROCESS
//#define ULTRA_LPW_BOARD_EVM_1T1R_800M
//#define ULTRA_LPW_BOARD_EVM_1T1R_800M_PROCESS

//#define BOARD_EVM_1T2R_220M
//#define BOARD_EVM_1T2R_220M_PROCESS
//#define ULTRA_LPW_BOARD_EVM_1T2R_220M
//#define ULTRA_LPW_BOARD_EVM_1T2R_220M_PROCESS
//#define BOARD_EVM_1T2R_800M
//#define BOARD_EVM_1T2R_800M_PROCESS
//#define ULTRA_LPW_BOARD_EVM_1T2R_800M
//#define ULTRA_LPW_BOARD_EVM_1T2R_800M_PROCESS


//#define BOARD_EVM2_1T2R_220M
//#define BOARD_EVM2_1T2R_220M_PROCESS
//#define ULTRA_LPW_BOARD_EVM2_1T2R_220M
//#define ULTRA_LPW_BOARD_EVM2_1T2R_220M_PROCESS
//#define BOARD_EVM2_1T2R_800M
//#define BOARD_EVM2_1T2R_800M_PROCESS
//#define ULTRA_LPW_BOARD_EVM2_1T2R_800M
//#define ULTRA_LPW_BOARD_EVM2_1T2R_800M_PROCESS

/* 目标板 */
#if \
defined( BOARD_EVB_220M ) || \
defined( BOARD_EVB_220M_PROCESS ) || \
defined( BOARD_EVB_800M ) || \
defined( BOARD_EVB_800M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVB_220M ) || \
defined( ULTRA_LPW_BOARD_EVB_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVB_800M ) || \
defined( ULTRA_LPW_BOARD_EVB_800M_PROCESS )
#define BOARD_ID                (1)  // 1-EVB
#endif

#if \
defined( BOARD_EVM_1T2R_220M ) || \
defined( BOARD_EVM_1T2R_220M_PROCESS ) || \
defined( BOARD_EVM_1T2R_800M ) || \
defined( BOARD_EVM_1T2R_800M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T2R_220M ) || \
defined( ULTRA_LPW_BOARD_EVM_1T2R_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T2R_800M ) || \
defined( ULTRA_LPW_BOARD_EVM_1T2R_800M_PROCESS )
#if defined(BOARD_ID)
#error redefined board_id
#endif
#define BOARD_ID                (2)  //2-EVM-1T2R
#endif


#if \
defined( BOARD_EVM_1T1R_220M ) || \
defined( BOARD_EVM_1T1R_220M_PROCESS ) || \
defined( BOARD_EVM_1T1R_800M ) || \
defined( BOARD_EVM_1T1R_800M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T1R_220M ) || \
defined( ULTRA_LPW_BOARD_EVM_1T1R_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T1R_800M ) || \
defined( ULTRA_LPW_BOARD_EVM_1T1R_800M_PROCESS )
#if defined(BOARD_ID)
#error redefined board_id
#endif
#define BOARD_ID                (3)  // 3-EVM-1T1R
#endif

#if \
defined( BOARD_EVM2_1T2R_220M ) || \
defined( BOARD_EVM2_1T2R_220M_PROCESS ) || \
defined( BOARD_EVM2_1T2R_800M ) || \
defined( BOARD_EVM2_1T2R_800M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM2_1T2R_220M ) || \
defined( ULTRA_LPW_BOARD_EVM2_1T2R_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM2_1T2R_800M ) || \
defined( ULTRA_LPW_BOARD_EVM2_1T2R_800M_PROCESS )
#if defined(BOARD_ID)
#error redefined board_id
#endif
#define BOARD_ID                (4)  //4: EVM2-1T2R
#endif

/*是否超低功耗*/
#if \
defined( ULTRA_LPW_BOARD_EVB_220M ) || \
defined( ULTRA_LPW_BOARD_EVB_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVB_800M ) || \
defined( ULTRA_LPW_BOARD_EVB_800M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T2R_220M ) || \
defined( ULTRA_LPW_BOARD_EVM_1T2R_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T2R_800M ) || \
defined( ULTRA_LPW_BOARD_EVM_1T2R_800M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM2_1T2R_220M ) || \
defined( ULTRA_LPW_BOARD_EVM2_1T2R_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM2_1T2R_800M ) || \
defined( ULTRA_LPW_BOARD_EVM2_1T2R_800M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T1R_220M ) || \
defined( ULTRA_LPW_BOARD_EVM_1T1R_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T1R_800M ) || \
defined( ULTRA_LPW_BOARD_EVM_1T1R_800M_PROCESS )
#define ULTRA_LPW   (1)                 // 超低功耗
#else
#define ULTRA_LPW   (0)                 // 低功耗
#endif

/*带宽*/
#if \
defined( BOARD_EVM_1T1R_220M ) || \
defined( BOARD_EVM_1T1R_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T1R_220M ) || \
defined( ULTRA_LPW_BOARD_EVM_1T1R_220M_PROCESS ) || \
defined( BOARD_EVM_1T2R_220M ) || \
defined( BOARD_EVM_1T2R_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T2R_220M ) || \
defined( ULTRA_LPW_BOARD_EVM_1T2R_220M_PROCESS ) || \
defined( BOARD_EVM2_1T2R_220M ) || \
defined( BOARD_EVM2_1T2R_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM2_1T2R_220M ) || \
defined( ULTRA_LPW_BOARD_EVM2_1T2R_220M_PROCESS ) || \
defined( BOARD_EVB_220M ) || \
defined( BOARD_EVB_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVB_220M ) || \
defined( ULTRA_LPW_BOARD_EVB_220M_PROCESS )
#define RAMP_BANDWIDTH          (0) // 220M
#else
#define RAMP_BANDWIDTH          (1) // 800M
#endif

/*是否开启后处理*/
#if \
defined( BOARD_EVM_1T1R_220M_PROCESS ) || \
defined( BOARD_EVM_1T1R_800M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T1R_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T1R_800M_PROCESS ) || \
defined( BOARD_EVM_1T2R_220M_PROCESS ) || \
defined( BOARD_EVM_1T2R_800M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T2R_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM_1T2R_800M_PROCESS ) || \
defined( BOARD_EVM2_1T2R_220M_PROCESS ) || \
defined( BOARD_EVM2_1T2R_800M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM2_1T2R_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVM2_1T2R_800M_PROCESS ) || \
defined( BOARD_EVB_220M_PROCESS ) || \
defined( BOARD_EVB_800M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVB_220M_PROCESS ) || \
defined( ULTRA_LPW_BOARD_EVB_800M_PROCESS )
#define POINTRST_USER_PROCESS   (1)  // 点云处理
#else
#define POINTRST_USER_PROCESS   (0)  // 点云处理
#endif


#if !defined(BOARD_ID) || !defined(RAMP_BANDWIDTH) || !defined(POINTRST_USER_PROCESS) || !defined(ULTRA_LPW)
#error xxxx
//#else
//#if( BOARD_ID == 1 )
//#warning BOARD_ID 1
//#elif( BOARD_ID == 2 )
//#warning BOARD_ID 2
//#elif( BOARD_ID == 3 )
//#warning BOARD_ID 3
//#else
//#error df
//#endif

//#if( RAMP_BANDWIDTH == 0 )
//#warning RAMP_BANDWIDTH 0
//#else
//#warning RAMP_BANDWIDTH 1
//#endif

//#if( POINTRST_USER_PROCESS == 0 )
//#warning POINTRST_USER_PROCESS 0
//#else
//#warning POINTRST_USER_PROCESS 1
//#endif

//#if( ULTRA_LPW == 0 )
//#warning ULTRA_LPW 0
//#else
//#warning ULTRA_LPW 1
//#endif
#endif

#define DEMO_RX_ANT_NUM (2)  // 1-1T1R 2-1T2R

#endif

#if ( BOARD_ID == 3 )
#ifdef DEMO_RX_ANT_NUM
#undef DEMO_RX_ANT_NUM
#endif
#define DEMO_RX_ANT_NUM (1)
#define LIGHT_DETECT // 光线检测
// 1T1R 主板有光敏电阻 用于检测光照
/*
	gpio0.1 ----100K-----photoresister---gpio0.2
	                                        |
																					= (10nF)
																					|
																				 GND
*/
#endif
#endif

#if 1 /* 应用配置 */

//#define SINGLE_TARGET // 只跟踪单目标，客户需进一步完善逻辑策略
		

#define FILTER_SELECT_MEAN  (0)
#define FILTER_SELECT_ALPHA (1)
#define FILTER_SELECT (1) // 0-mean_filter 1-alpha_filter

#define PT_CACHE  (1) //点云v10/v11协议 // 0-不显示历史10帧 1-显示历史10帧
#define PT_STYLE  (2) //点云v10/v11协议 // 0-小点 1-中点 2-大点
#define EXT_ABS   (1) //点云v10协议     // 本demo 不可更改必须为1


#define DEMO_CHIRP_NUM  (32) // max:32 默认32,支持16/8；16/8待调测

//#define LED_ENABLE
#if defined(LED_ENABLE)
#define LED_OUTPUT_MODE     (0) // 0-OD 1-PP
#define LED_OUTPUT_PIN      (4) // gpio0.x  // 本demo只支持GPIO0.4
#define LED_OUTPUT_ACTIVE   (0) // 0-low 1-high
#endif

//#define GPIO_OUTPUT_ENABLE
#if defined(GPIO_OUTPUT_ENABLE)
#define GPIO_OUTPUT_MODE    (1) // 0-OD 1-PP
#define GPIO_OUTPUT_PIN     (5) // gpio0.x
#define GPIO_OUTPUT_ACTIVE  (1) // 0-low 1-high
#endif

/*应用功能开关*/
#define FLASH_WINRANGE // 窗函数@flash
// 串口接收
#define UART_RECV_ENABLE

// 只保留各速度最近点
//#define LOWPOWER_ENABLE
#define POINT_NEAREST (1)
#define PRESENCE_ENABLE

#define FRAME_INTERVAL_MS  (100)
#define FRAME_PER_SEC      (1000/FRAME_INTERVAL_MS)?(1000/FRAME_INTERVAL_MS):1


#define DBSCAN_ENABLE
#if (POINTRST_USER_PROCESS == 1 ) 
#define POINTRST_USER_PROCESS_PER_N_FRAME (1)   // 默认每2帧后处理一次。支持1或2
#define SWITCH_INNER_UDF (1)                    // 使用udf01做点云处理
#define DEMO_PRESENCE_TARGET_TIMEOUT (7200)  // 长时间静止点超时时间60S
#define MINUS_MODE_SWITCH                       // 减均值模式切换，FFT2D_MINUS_MEAN_MODE==1时有效
#endif


// 点云输出
#define POINTRST_ENABLE
#if defined(POINTRST_ENABLE)
#define POINTRST_USER_PROTOCOL      // 用户自定义点云输出协议
#define POINTRST_INTERFACE            (0)   // 0 uart  1 spi
#if (POINTRST_USER_PROCESS == 1 )    // 点云处理模式输出点云帧率可调
#define POINTRST_FREQUENCY            (10) // POINTRST_USER_PROCESS_PER_N_FRAME==2 时 最大10hz 最小1hz ==1时：最大20hz
#endif
#endif

// 减均值模式
#define FFT2D_MINUS_MEAN_MODE (0) // 0-减本帧均值 1-减上帧均值 2-减(帧间均值加权做为均值)
// 距离维加窗
//#define RANGE_WIN_ENABLE
// 速度维加窗
//#define VEL_WIN_ENABLE

#endif

#if 1 /* 基础配置 */
#define DYNALOAD_FW         (0) // 0-flash固件 1-动态加载固件
#define FLASH_INTERFACE     (0) // 0-single spi 1-qspi
#define UART_BAUDRATE       (1) // 0-2000000 1-115200
#define UDF03_ROM_FUNCTION2 (0) // UDF03复刻ROM_FUNC2 0-不开启 1-开启  注: 本demo不支持开启
#endif


#if 1 /* 客制化数据配置 */

//#define CUSTOM_DATA_ENABLE

#ifdef  CUSTOM_DATA_ENABLE
// 客制化数据输出接口
#define CUSTOM_DATA_INTERFACE         (0) // 0 uart  1 spi
// 客制化数据输出格式
#define CUSTOM_DATA_FORMAT_ROW_COLUMN (0) // 0 chirp-row 1 chirp-column
// 客制化数据输出协议
#define CUSTOM_DATA_PROTOCOL_VER      (0) // 0-raw data 1-v1.0 protocol 2-v2.x protocol
#endif

#endif

#if 1 /* 调试配置 */
// ==1 - 天线1 
// ==2 - 天线2
// <3  - 天线1、天线2
// ==0 - 无 

#define LOG_LEVEL             ( LOG_LEVEL_EMERG )
#define TEST_MODE_LOG_LEVEL   ( LOG_LEVEL_EMERG )

#if !defined(DEBUG_DATA_ANT_FILTER)
#define DEBUG_DATA_ANT_FILTER(x)   (x==1)
#endif

// 调试数据输出帧协议
#define DEBUG_DATA_PROTOCOL_VER      (1) // 0-raw data 1-v1.0 protocol 2-v2.0 protocol
// 调试数据输出格式
#define DEBUG_DATA_FORMAT_ROW_COLUMN (0) // 0 chirp-row 1 chirp-column
// 调试数据输出接口
#define DEBUG_DATA_INTERFACE         (0) // 0 uart  1 spi
#endif
#define DEBUG (0)
#endif

